package com.xxx.modules.controller;;
import com.xxx.modules.service.SeveService;
import com.xxx.modules.entity.Seve;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * seve
 *
 * @author 北易航
 * @since 1.0.0 2023-02-05
 */
@RestController
@RequestMapping("/common/seve")
@Api(tags="seve")
public class SeveController {
    @Autowired
    private SeveService seveService;

    /**
    *  获取所有服务信息
    * @param pageNum
    * @param pageSize
    * @param seve
    * @return
    */

    @GetMapping("/getSeveInfo")
    @ApiOperation("获取所有服务信息")
    public Result getSeveInfo(Seve seve, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Seve> data = seveService.selectSeveInfo(seve,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存服务信息
    * @param seve
    * @return
    */
    @PostMapping("/saveSeveInfo")
    @ApiOperation("保存服务信息")
    public Result saveSeveInfo(@RequestBody Seve seve){
        seveService.saveSeveInfo(seve);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新服务信息
     * @param seve
     * @return
     */

    @PutMapping("/updateSeveInfo")
    @ApiOperation("更新服务信息")
    public Result updateSeveInfo(@RequestBody Seve seve){
        seveService.updateSeveInfo(seve);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除服务信息
     * @param id
     * @return
     */
    @DeleteMapping("/delSeveInfo")
    @ApiOperation("根据id删除服务信息")
    public Result delSeveInfo(Integer id){
        seveService.delSeveInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除服务信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchSeveInfo")
    @ApiOperation("根据id集合批量删除服务信息")
    public Result delBatchSeveInfo(String idList){
        seveService.delBatchSeveInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}